package com.sskj.quantization.http;
import com.sskj.quantization.bean.ProfitAllBean;
import com.sskj.quantization.bean.QuanRecordBean;
import com.sskj.quantization.bean.CashBeforeBean;
import com.lzy.okgo.request.PostRequest;
import com.sskj.lib.bean.PageBean;
import com.sskj.quantization.bean.ProfitBean;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.GetRequest;
import com.sskj.common.base.HttpData;
import com.sskj.quantization.bean.QuanBean;


/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {




    /**
     * 合约首页
     *
     * @return
     */
    public GetRequest<HttpData<QuanBean>> getQuanData(){
        return OkGo.<HttpData<QuanBean>>get(HttpConfig.BASE_URL + HttpConfig.GET_QUAN_DATA);
    }

    /**
     * 我的收益
     *
     * @param p 页码，默认1
     * @param size 页条数，默认5
     * @return
     */
    public PostRequest<HttpData<PageBean<ProfitBean>>> getProfitList(String p, String size){
        return OkGo.<HttpData<PageBean<ProfitBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_PROFIT_LIST)
                .params("p", p)
                .params("size", size);
    }
    /**
     * 我的收益
     *

     * @return
     */
    public PostRequest<HttpData<ProfitAllBean>> getProfit(){
        return OkGo.<HttpData<ProfitAllBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_PROFIT_LIST)
                .params("p", 1)
                .params("size", 1);
    }

    /**
     * 确认兑换
     *
     * @param id 合约ID
     * @param tpwd 交易密码
     * @return
     */
    public PostRequest<HttpData> cash(String id,String tpwd){
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CASH)
                .params("id", id)
                .params("tpwd", tpwd);
    }

    /**
     * 兑换合约前页面
     *
     * @param id 合约ID
     * @return
     */
    public PostRequest<HttpData<CashBeforeBean>> cashBefore(String id){
        return OkGo.<HttpData<CashBeforeBean>>post(HttpConfig.BASE_URL + HttpConfig.CASH_BEFORE)
                .params("id", id);
    }

    /**
     * 量化记录
     *
     * @param type 1持有 2 完成
     * @param p 页码，默认1
     * @param size 页条数，默认5
     * @return
     */
    public PostRequest<HttpData<PageBean<QuanRecordBean>>> quanRecord(String type,String p,String size){
        return OkGo.<HttpData<PageBean<QuanRecordBean>>>post(HttpConfig.BASE_URL + HttpConfig.QUAN_RECORD)
                .params("type", type)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 购买合约
     *
     * @param tpwd 交易密码
     * @return
     */
    public PostRequest<HttpData> buy(String tpwd){
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.BUY)
                .params("tpwd", tpwd);
    }


}